home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / UTIL / CD Playthrough 1.5.sit / CD Playthrough 1.5 / Source / Prefs.c < prev    next >
Text File  |  1996-11-20  |  3KB  |  100 lines

  1. //    CD Playthrough
  2. //    Version: 1.5 <October 3, 1994>
  3. //    (c)    1994 neg.active.productions, jwang@csua.berkeley.edu <James    Wang>  
  4. //    ftp://ftp.csua.berkeley.edu/pub/jwang/cool/cd-playthrough-15.hqx
  5.  
  6. //    File:            Prefs.c
  7. //
  8. //    Contains:        Preferences reading and writing sub-routines
  9. //
  10. //    Written by:        James Wang
  11. //
  12. //    Description:    CD Playthrough modifies its own resources ('PREF') to remember 
  13. //                    the "user" mode options.  This file needs to be re-written to
  14. //                    use bona fide preference files (with drag-n-drop).  Any takers?
  15.  
  16.  
  17. #include "main.h"
  18.  
  19.  
  20. Str31        sourStr,  plthStr,  rateStr;
  21. Handle        sourHand, plthHand, rateHand;
  22.  
  23.  
  24. void res_check(SoundSetting *mySnd)
  25. {
  26.     sourHand = Get1Resource('PREF', kSourPrefID);
  27.     if (sourHand == 0)
  28.     {
  29.         sourHand = NewHandle(1);
  30.         if (sourHand == 0) stop_alert(MemFull);
  31.         **sourHand = kSourCD;
  32.         AddResource(sourHand, 'PREF', kSourPrefID, "¥pInput Source");
  33. //        handle_res_error(ResError());
  34.     }
  35.  
  36.     plthHand = Get1Resource('PREF', kPlthPrefID);
  37.     if (plthHand == 0)
  38.     {
  39.         plthHand = NewHandle(1);
  40.         if (plthHand == 0) stop_alert(MemFull);
  41.         **plthHand = kPlthMax;
  42.         AddResource(plthHand, 'PREF', kPlthPrefID, "¥pPlaythrough Level");
  43. //        handle_res_error(ResError());
  44.     }
  45.  
  46.     rateHand = Get1Resource('PREF', kRatePrefID);
  47.     if (rateHand == 0)
  48.     {
  49.         rateHand = NewHandle(6);
  50.         if (rateHand == 0) stop_alert(MemFull);
  51.         NumToString(44100L, *((StringHandle)rateHand));
  52.         AddResource(rateHand, 'PREF', kRatePrefID, "¥pSound Out Rate");
  53. //        handle_res_error(ResError());
  54.     }
  55. }
  56.  
  57. void read_prefs(SoundSetting *mySnd)
  58. {
  59.     long            myRate;
  60.  
  61.     res_check(mySnd);
  62.     mySnd->siWantSour = (short)**sourHand;
  63.     mySnd->siWantPlth = (short)**plthHand;
  64.     StringToNum(*((StringHandle)rateHand), &myRate);
  65.     mySnd->soWantRate = myRate<<16;
  66. }
  67.  
  68. void save_prefs(SoundSetting *mySnd)
  69. {
  70.     res_check(mySnd);
  71.  
  72.     GetIndString(sourStr, kSourStrID, mySnd->siCurrSour);
  73.     GetIndString(plthStr, kPlthStrID, mySnd->siCurrPlth+1);
  74.     NumToString(mySnd->soCurrRate>>16, rateStr);
  75.  
  76.     ParamText(sourStr, plthStr, rateStr, 0);
  77.     if (CautionAlert(kCautionAlertID, 0) == 2) return;
  78.  
  79.     **sourHand = (char)mySnd->siCurrSour;
  80.     **plthHand = (char)mySnd->siCurrPlth;
  81.     SetString((StringHandle)rateHand, rateStr);
  82.  
  83.     ChangedResource(sourHand);
  84.     ChangedResource(plthHand);
  85.     ChangedResource(rateHand);
  86. //    handler_res_error(ResError());
  87. }
  88.  
  89. void system_prefs(SoundSetting *mySnd)
  90. {
  91.     mySnd->siWantSour = kSourAV;
  92.     mySnd->siWantPlth = kPlthMin;
  93.  
  94.     // lame machine identity test
  95.     if (desired_rate_available(kRate24000))
  96.         mySnd->soWantRate = kRate24000;        // we have a 660av or 840av
  97.     else
  98.         mySnd->soWantRate = kRate22050;        // assume a Power Macintosh
  99. }
  100.